package com.base.moduleUser.service.impl;


import com.base.core.common.utils.JwtUtils;
import com.base.core.domain.User;
import com.base.moduleUser.service.UserRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class UserRedisServiceImpl implements UserRedisService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private JwtUtils jwtUtils;
    @Override
    public User getUserByToken(String token) {
        String username= jwtUtils.getSubjectFromToken(token);
        User user = (User) redisTemplate.opsForValue().get("user:token"+username);
        return user;
    }
}
